home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / GAUGE.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  5KB  |  187 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //
  7. // Definition of class TGauge, a gauge control encapsulation & implementation.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_GAUGE_H)
  10. #define OWL_GAUGE_H
  11.  
  12. #if !defined(OWL_CONTROL_H)
  13. # include <owl/control.h>
  14. #endif
  15. #if !defined(WINSYS_COLOR_H)
  16. # include <winsys/color.h>
  17. #endif
  18. #if !defined(OWL_COMMCTRL_H)
  19. # include <owl/commctrl.h>
  20. #endif
  21.  
  22. #if defined(BI_NAMESPACE)
  23. namespace OWL {
  24. #endif
  25.  
  26. // Generic definitions/compiler options (eg. alignment) preceeding the
  27. // definition of classes
  28. #include <services/preclass.h>
  29.  
  30. //
  31. // class TGauge
  32. // ~~~~~ ~~~~~~
  33. class _OWLCLASS TGauge : public TControl {
  34.   public:
  35.     TGauge(TWindow*        parent,
  36.            const char far* title,
  37.            int             id,
  38.            int x, int y, int w, int h = 0,
  39.            bool            isHorizontal = true,
  40.            int             margin = 1,
  41.            TModule*        module = 0);
  42.  
  43.     TGauge(TWindow*        parent,
  44.            int             id,
  45.            int x, int y, int w, int h = 0,
  46.            TModule*        module = 0);
  47.  
  48.     TGauge(TWindow*        parent,
  49.            int             resId,
  50.            TModule*        module = 0);
  51.  
  52.     // Getting & setting gauge properties
  53.     //
  54.     void          GetRange(int& min, int& max) const;
  55.     int           GetStep() const;
  56.     int           GetValue() const;
  57.  
  58.     void          SetRange(int min, int max);
  59.     void          SetStep(int step);
  60.     void          SetValue(int value);  
  61.     void          DeltaValue(int delta);
  62.     void          StepIt();
  63.     void operator ++(int);
  64.  
  65.     // Set whether the control is horizontal. This method is useful
  66.     // for an object coming from a dialog resource. [For objects created
  67.     // by OWL, use the constructor which accepts a boolean 'isHorizontal'
  68.     // parameter.
  69.     //
  70.     void          SetHorizontal(bool horizontal);
  71.  
  72.     // Set the LED style & sizing as well as the indicator color
  73.     // Ignored by CommonControl impl.
  74.     //
  75.     // NOTE: Invoking these methods may *NOT* be effective if OWL
  76.     //       uses the Common Control support and instead of 
  77.     //       emulating the control.
  78.     //
  79.     void          SetLed(int spacing, int thickPercent = 90);
  80.     void          SetColor(const TColor& color);
  81.  
  82.     // Specifies whether OWL should use or avoid the system implementation
  83.     // of gauge/progressbar if/when available.
  84.     //
  85.     void          SetNativeUse(TNativeUse nu = nuDontCare);
  86.  
  87.   protected:
  88.  
  89.     // Override TWindow virtual member functions
  90.     //
  91.     char far*     GetClassName();
  92.     void          Paint(TDC& dc, bool erase, TRect& rect);
  93.     void          SetupWindow();
  94.  
  95.     // Self sent by method Paint(). override this is if you want to
  96.     // implement a border style that isn't supported
  97.     //
  98.     virtual void  PaintBorder(TDC& dc);
  99.  
  100.     // Message response functions
  101.     //
  102.     bool          EvEraseBkgnd(HDC);
  103.  
  104.   protected_data:
  105.     int           Min;        // Minimum value
  106.     int           Max;        // Maximum value
  107.     int           Value;      // Current value (position)
  108.     int           Step;       // Step factor
  109.     int           Margin;     // margin between bevel & graphic
  110.     int           IsHorizontal;
  111.     int           LedSpacing; // Spacing of 'leds' in value units
  112.     int           LedThick;   // Thickness of leds in percent of spacing
  113.     TColor        BarColor;   // Bar or LED color, defaults to blue
  114.     static TNativeUse ClassNativeUse;  // Default use of native control impl
  115.  
  116.   private:
  117.     // Hidden to prevent accidental copying or assignment
  118.     //
  119.     TGauge(const TGauge&);
  120.     TGauge& operator=(const TGauge&);
  121.  
  122.   DECLARE_RESPONSE_TABLE(TGauge);
  123. };
  124.  
  125. // Generic definitions/compiler options (eg. alignment) following the
  126. // definition of classes
  127. #include <services/posclass.h>
  128.  
  129. #if defined(BI_NAMESPACE)
  130. } // namespace OWL
  131. #endif
  132.  
  133. //----------------------------------------------------------------------------
  134. // Inline implementations
  135.  
  136. //
  137. inline void TGauge::GetRange(int& min, int& max) const
  138. {
  139.   min = Min; max = Max;
  140. }
  141.  
  142. //
  143. // Return the step factor
  144. //
  145. inline int TGauge::GetStep() const
  146. {
  147.   return Step;
  148. }
  149.  
  150. //
  151. inline int TGauge::GetValue() const
  152. {
  153.   return Value;
  154. }
  155.  
  156. //
  157. // Another way of stepping (calls StepIt)
  158. //
  159. inline void TGauge::operator ++(int)
  160. {
  161.   StepIt();
  162. }
  163.  
  164. //
  165. inline void TGauge::SetColor(const TColor& color)
  166. {
  167.   BarColor = color;
  168. }
  169.  
  170. //
  171. // Specifies whether the class uses the native (operating system) implementation
  172. // or emulates it.
  173. //
  174. inline void TGauge::SetNativeUse(TNativeUse nu)
  175. {
  176.   NativeUse = nu;
  177. }
  178.  
  179. // Specifies whether the control is a horizontal (or vertical) gauge control
  180. //
  181. inline void TGauge::SetHorizontal(bool isHorizontal)
  182. {
  183.   IsHorizontal = isHorizontal;
  184. }
  185.  
  186. #endif  // OWL_GAUGE_H
  187.